# 提供给其它项目引用的共享资源(如果想通过框架构建引用的话）
if(FRAMEWORK_WANT_INCLUDE)

    set(PREFIX_DIR 
        ${CMAKE_CURRENT_LIST_DIR}/Qt-Advanced-Docking-System)

    set(ads_QRCS 
        ${PREFIX_DIR}/src/ads.qrc
    )

    set(ads_SRCS
        ${PREFIX_DIR}/src/ads_globals.cpp
        ${PREFIX_DIR}/src/DockAreaTabBar.cpp
        ${PREFIX_DIR}/src/DockAreaTitleBar.cpp
        ${PREFIX_DIR}/src/DockAreaWidget.cpp
        ${PREFIX_DIR}/src/DockContainerWidget.cpp
        ${PREFIX_DIR}/src/DockManager.cpp
        ${PREFIX_DIR}/src/DockOverlay.cpp
        ${PREFIX_DIR}/src/DockSplitter.cpp
        ${PREFIX_DIR}/src/DockWidget.cpp
        ${PREFIX_DIR}/src/DockWidgetTab.cpp
        ${PREFIX_DIR}/src/DockingStateReader.cpp
        ${PREFIX_DIR}/src/DockFocusController.cpp
        ${PREFIX_DIR}/src/ElidingLabel.cpp
        ${PREFIX_DIR}/src/FloatingDockContainer.cpp
        ${PREFIX_DIR}/src/FloatingDragPreview.cpp
        ${PREFIX_DIR}/src/IconProvider.cpp
        ${PREFIX_DIR}/src/DockComponentsFactory.cpp
        ${PREFIX_DIR}/src/AutoHideSideBar.cpp
        ${PREFIX_DIR}/src/AutoHideTab.cpp
        ${PREFIX_DIR}/src/AutoHideDockContainer.cpp
        ${PREFIX_DIR}/src/PushButton.cpp
        ${PREFIX_DIR}/src/ResizeHandle.cpp
    )
    set(ads_HEADERS
        ${PREFIX_DIR}/src/ads_globals.h
        ${PREFIX_DIR}/src/DockAreaTabBar.h
        ${PREFIX_DIR}/src/DockAreaTitleBar.h
        ${PREFIX_DIR}/src/DockAreaTitleBar_p.h
        ${PREFIX_DIR}/src/DockAreaWidget.h
        ${PREFIX_DIR}/src/DockContainerWidget.h
        ${PREFIX_DIR}/src/DockManager.h
        ${PREFIX_DIR}/src/DockOverlay.h
        ${PREFIX_DIR}/src/DockSplitter.h
        ${PREFIX_DIR}/src/DockWidget.h
        ${PREFIX_DIR}/src/DockWidgetTab.h
        ${PREFIX_DIR}/src/DockingStateReader.h
        ${PREFIX_DIR}/src/DockFocusController.h
        ${PREFIX_DIR}/src/ElidingLabel.h
        ${PREFIX_DIR}/src/FloatingDockContainer.h
        ${PREFIX_DIR}/src/FloatingDragPreview.h
        ${PREFIX_DIR}/src/IconProvider.h
        ${PREFIX_DIR}/src/DockComponentsFactory.h
        ${PREFIX_DIR}/src/AutoHideSideBar.h
        ${PREFIX_DIR}/src/AutoHideTab.h
        ${PREFIX_DIR}/src/AutoHideDockContainer.h
        ${PREFIX_DIR}/src/PushButton.h
        ${PREFIX_DIR}/src/ResizeHandle.h
    )

    # add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
    if (UNIX AND NOT APPLE)
        set(ads_SRCS ${PREFIX_DIR}/src/linux/FloatingWidgetTitleBar.cpp ${ads_SRCS})
        set(ads_HEADERS ${PREFIX_DIR}/src/linux/FloatingWidgetTitleBar.h ${ads_HEADERS})
    endif()


    if(NOT TARGET ads)
        add_library(ads ${ads_QRCS} ${ads_SRCS} ${ads_HEADERS})
        target_compile_definitions(ads PUBLIC ADS_STATIC)
        target_include_directories(ads PUBLIC ${PREFIX_DIR}/src)
        target_link_libraries(ads Qt${QT_VERSION_MAJOR}::Core
                                                    Qt${QT_VERSION_MAJOR}::Gui
                                                    Qt${QT_VERSION_MAJOR}::Widgets)

        if (UNIX AND NOT APPLE)
            if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
                find_package(X11 REQUIRED)
                target_link_libraries(ads PUBLIC X11::xcb)
            else()
                target_link_libraries(ads xcb)
            endif()
        endif()

        include_directories(${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS})

        if(QT_VERSION_MAJOR STREQUAL "5")
            set_target_properties(ads PROPERTIES
                CXX_STANDARD 14
                CXX_STANDARD_REQUIRED ON)
        elseif(QT_VERSION_MAJOR STREQUAL "6")
            set_target_properties(ads PROPERTIES
                CXX_STANDARD 17
                CXX_STANDARD_REQUIRED ON)
        endif()

        target_compile_definitions(ads PUBLIC ADS_STATIC)
        if (UNIX AND NOT APPLE)
            if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
                find_package(X11 REQUIRED)
                target_link_libraries(ads X11::xcb)
            else()
                target_link_libraries(ads xcb)
            endif()
        endif()

        if(QT_VERSION_MAJOR STREQUAL "5")
            set_target_properties(ads PROPERTIES
                CXX_STANDARD 14
                CXX_STANDARD_REQUIRED ON)
        elseif(QT_VERSION_MAJOR STREQUAL "6")
            set_target_properties(ads PROPERTIES
                CXX_STANDARD 17
                CXX_STANDARD_REQUIRED ON)
        endif()

        add_library(qtadvanceddocking-qt${QT_VERSION_MAJOR} ALIAS ads)

        if(feature_ads_examples)
            spark_add_executable_path(ads-examples-autohide
                ${PREFIX_DIR}/examples/autohide)
                target_link_libraries(ads-examples-autohide PRIVATE ads)
            spark_add_executable_path(ads-examples-autohidedragndrop
                ${PREFIX_DIR}/examples/autohidedragndrop)
                target_link_libraries(ads-examples-autohidedragndrop PRIVATE ads)
            spark_add_executable_path(ads-examples-centralwidget
                ${PREFIX_DIR}/examples/centralwidget)
                target_link_libraries(ads-examples-centralwidget PRIVATE ads)
            spark_add_executable_path(ads-examples-configflags
                ${PREFIX_DIR}/examples/configflags)
                target_link_libraries(ads-examples-configflags PRIVATE ads)
            spark_add_executable_path(ads-examples-deleteonclose
                ${PREFIX_DIR}/examples/deleteonclose)
                target_link_libraries(ads-examples-deleteonclose PRIVATE ads)
            spark_add_executable_path(ads-examples-emptydockarea
                ${PREFIX_DIR}/examples/emptydockarea)
                target_link_libraries(ads-examples-emptydockarea PRIVATE ads)
            spark_add_executable_path(ads-examples-hideshow
                ${PREFIX_DIR}/examples/hideshow)
                target_link_libraries(ads-examples-hideshow PRIVATE ads)
            spark_add_executable_path(ads-examples-sidebar
                ${PREFIX_DIR}/examples/sidebar)
                target_link_libraries(ads-examples-sidebar PRIVATE ads)
            spark_add_executable_path(ads-examples-simple
                ${PREFIX_DIR}/examples/simple)
                target_link_libraries(ads-examples-simple PRIVATE ads)
        endif(feature_ads_examples)

    endif(NOT TARGET ads)

    set(FRAMEWORK_INCLUDE_EXPORTS      # 共享的引用目录
        ${PREFIX_DIR}/src
    )
    set(FRAMEWORK_SOURCES_EXPORTS      # 共享的资源文件
        ${ads_QRCS}
    )

    set(FRAMEWORK_WITHGIT_EXPORTS      # 共享的引用构建资源
        # 1. 引用了公共存储库
        # https://gitee.com/ndd-community/framework-plugin-component-library

        # 2. 引用了该项目提供的 - 间接引用 QFtp
        # https://gitee.com/spark-framework-libs/QFtpExample
        # https://gitee.com/spark-framework-libs/QFtp

        # 3. 引用了该项目提供的 Drag/Drop Eaters 与 EventUtil
        # https://gitee.com/zinface/notepad--plugin.image-view
    )

    # 特殊构建 - 为引用资源的目标配置预期所需依赖的构建
        # FRAMEWORK_PLUGIN 引用本资源的框架目标变量
    # find_package(Qt5Svg)
    # target_link_libraries(${FRAMEWORK_PLUGIN} Qt5::Svg)

    target_link_libraries(${FRAMEWORK_PLUGIN} ads)

    return()
endif(FRAMEWORK_WANT_INCLUDE)
